package nl.hanze.designpatterns.mvc.model;

import nl.hanze.designpatterns.DAO.impl.db.LoginCredentialsDaoImpl;
import nl.hanze.designpatterns.domain.LoginCredential;

public class LoginModel {
	
	private LoginCredential loginCredential;
	private LoginCredentialsDaoImpl validLogin;
    
	public LoginModel(){
		this.init();
	}
	
	private void init(){
		this.validLogin = new LoginCredentialsDaoImpl();
	}
	
	public Boolean isLoggedIn(){
		if(this.loginCredential != null ){
			return true;
		}else{
			return false;
		}
	}
	
	public boolean isValid(LoginCredential loginCredential){
		if(validLogin.isValid(loginCredential)){
			this.loginCredential = loginCredential;
			return true;
		}
		return false;
	}
	
	public void setLogin(LoginCredential loginCredential){
		this.loginCredential = loginCredential;
	}
	
	public LoginCredential getLoginCredential(){
		return this.loginCredential;
	}
}
